home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / stdlib / RCS / strtol.man,v < prev    next >
Encoding:
Text File  |  1989-01-06  |  3.0 KB  |  95 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @@;
  7.  
  8.  
  9. 1.1
  10. date     89.01.05.17.59.48;  author ouster;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @' Copyright 1989 Regents of the University of California
  26. ' Permission to use, copy, modify, and distribute this
  27. ' documentation for any purpose and without fee is hereby
  28. ' granted, provided that this notice appears in all copies.
  29. ' The University of California makes no representations about
  30. ' the suitability of this material for any purpose.  It is
  31. ' provided "as is" without express or implied warranty.
  32. ' $Header: /sprite/lib/forms/RCS/proto.man,v 1.1 88/12/29 17:09:50 ouster Exp $ SPRITE (Berkeley)
  33. .so \*(]ltmac.sprite
  34. .HS strtol cmds
  35. .BS
  36. .SH NAME
  37. strtol, strtoul \- Convert character string to integer
  38. .SH SYNOPSIS
  39. .nf
  40. \fB#include <stdlib.h>
  41.  
  42. \fBlong int
  43. \fBstrtol(\fIstring\fR, \fIendPtr\fR, \fIbase\fR)
  44.  
  45. \fBunsigned long int
  46. \fBstrtoul(\fIstring\fR, \fIendPtr\fR, \fIbase\fR)
  47. .SH ARGUMENTS
  48. .AS "char *" endPtr
  49. .AP char *string in
  50. String containing ASCII representation of integer.
  51. .AP char **endPtr out
  52. If not \fBNULL\fR, gives address of pointer to fill in with address of
  53. first character in \fIstring\fR following integer.
  54. .AP int base in
  55. Base to use for conversion;  see below for explanation.  Must be
  56. between 0 and 36, inclusive.
  57. .BE
  58.  
  59. .SH DESCRIPTION
  60. .PP
  61. The \fBstrtol\fR and \fBstrtoul\fR procedures convert a character
  62. string to its corresponding integer representation and return the
  63. integer value.  Both procedures
  64. expect \fIstring\fR to point to a sequence of digits, optionally preceded
  65. by any amount of white space (as defined by the \fBisspace\fR procedure).
  66. \fBStrtol\fR also permits the digits to be preceded immediately by a
  67. minus sign, in which case the result is a negative integer.
  68. .PP
  69. If \fIbase\fR is between 2 and 36, inclusive, then the permissible
  70. ``digits'' of the string consist of the first \fIbase\fR characters
  71. in the set \fB0\fR through \fB9\fR and \fBa\fR through \fBz\fR
  72. (or \fBA\fR through \fBZ\fR).  The integer result will be calculated
  73. using \fIbase\fR as the radix for conversion.  If the value of \fIbase\fR
  74. is 16, then the characters \fB0x\fR or \fB0X\fR may precede the digits,
  75. following the sign if it is present.
  76. .PP
  77. If \fIbase\fR is 0, then the radix for conversion is chosen based on
  78. the initial digits of the number.  If the initial digits are \fB0x\fR
  79. or \fB0X\fR, then base 16 will be used for conversion;  otherwise if
  80. the first digit is \fB0\fR then base 8 will be used for conversion;
  81. otherwise base 10 will be used.
  82. .PP
  83. \fBStrtol\fR and \fBstrtoul\fR convert as many characters as possible
  84. from \fIstring\fR, and return in \fI*endPtr\fR the address of the first
  85. character not forming a valid portion of the number.  If no conversion
  86. could be performed (\fIstring\fR was empty, or did not point to a
  87. number in the expected form), then \fIstring\fR will be stored in
  88. \fI*endPtr\fR and zero is returned.
  89.  
  90. .SH KEYWORDS
  91. base, convert, integer, radix, string
  92. @
  93.